<!-- saved from url=(0026)/test.html -->
<html data-dpr="3" style="font-size: 37.5px;">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>骡窝窝问答,解决旅行问题,基于旅游的问答分享平台 - 骡窝窝</title>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui,viewport-fit=cover">
    <meta name="format-detection" content="telephone=no,address=no">
    <meta name="referrer" content="always" />
    <meta name="apple-mobile-web-app-capable" content="no" />
    <meta name="apple-mobile-web-app-status-bar-style" content="no" />

    <link href="/css/mobile+css+head_mobile+css+ui^YVw^1526627473.css" rel="stylesheet" type="text/css">
    <link href="/css/note.css" rel="stylesheet" type="text/css">
    <link href="/css/swiper-3.3.1.min.css" rel="stylesheet" type="text/css">

    <script src="/js/plugins/jquery/jquery.min.js"></script>
    <script src="/js/plugins/form/jquery.form.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>
    <style>
        .reply-wrap {
            padding: 2px 10px 0;
            resize: none;
        }
        .reply_box .reply_title {
            position:fixed;
            top:0;
        }
        .reply-wrap textarea {
            width: 100%;
            min-height: 120px;
            border-radius: 4px;
            background: #fff;
            text-indent: 0;
            overflow-x: hidden;
            overflow-y: auto;
            font-size: 18px;
            line-height: 1.2em;
            color: #666;
            text-align: left;
            outline: 0;
            border: 1px solid #fff;
            margin-top:48px;
        }
        .comment_lsit .cl_con img{
            max-width: 100%;
        }
    </style>
    <script>
        var params;
        var user;
        // 分页数据
        var currentPage = 1;
        var totalPage;
        var tCommentArr = [];

        function query(){
            // 查询游记评论
            $.get("/travels/"+params.travelId+"/comments/", {currentPage: currentPage, pageSize: 5}, function (data) {
                $.merge(tCommentArr, data.list);
                var json = {
                    list: tCommentArr
                };
                console.log(json);
                // 渲染数据
                $(".comment_detail").renderValues(json, {
                    getHref: function (item, value) {
                        var href = $(item).data("href");
                        $(item).attr('href', href + value);
                        $(item).attr('onclick', "addview("+value+")");
                    },
                    getRU: function (item, value) {
                        var html = $(item).siblings(".o").html();
                        console.log(value);
                        //setContent(item, html, value);
                        if (typeof value === "undefined"){
                            $(item).html(html);
                        } else {
                            $(item).html("回复"+value+": "+html);
                        }
                    },
                    replyBt: function (item, value) {
                        $(item).attr('onclick', "replyTo("+value+",this)");
                    }
                });
                totalPage = data.lastPage;
            });
            currentPage = currentPage + 1;
        }

        //
        function setContent(item, html, rid) {
        }

        // 回复某评论
        function replyTo(ru, item){
            if(!user){
                $(document).dialog({
                    type : 'confirm',
                    closeBtnShow: true,
                    content: '登陆后才可以评论, 现在登录?',
                    onClickConfirmBtn: function(){
                        location.href = "/login.html?authorId=666";
                    }
                });
            }else{
                $("#_js_replyBox").toggle();
                $("._j_submit").click(function () {
                    $.post("/travels/"+params.travelId+"/comments/save", {"replyToUser.id": ru, content: $("#_j_replyarea").val()},function (data) {
                        location.reload();
                    })
                });
            }
        }

        $(function () {
            params = getParams();
            user = JSON.parse(sessionStorage.getItem("user"));

            query();

            // 点击更多加载更多
            $("._j_more").click(function () {
                if (totalPage >= currentPage){
                    query();
                }else{
                    $(document).dialog({
                        type : 'notice',
                        infoText: '没有更多啦',
                        autoClose: 1000,
                        position: 'bottom'  // center: 居中; bottom: 底部
                    });
                }
            });

            if (params.travelId) {
                // 游记标题回显
                $.get("/travels/"+params.travelId, function (data) {
                    $("#headTitle").html("回复游记："+data.title);
                })
            }

            // 正常评论
            $("#_j_replyinput").click(function () {

                if(!user){
                    $(document).dialog({
                        type : 'confirm',
                        closeBtnShow: true,
                        content: '登陆后才可以评论, 现在登录?',
                        onClickConfirmBtn: function(){
                            location.href = "/login.html?authorId=666";
                        }
                    });
                }else{
                    $("#_js_replyBox").toggle();

                    $("._j_submit").click(function () {
                        console.log($("#_j_replyarea").html());
                        $.post("/travels/"+params.travelId+"/comments/save", {content: $("#_j_replyarea").val()},function (data) {
                            if (data.success){
                                location.reload();
                            }
                        })
                    });
                }
            });

            $("._j_close").click(function () {
                $("#_js_replyBox").toggle();
            });

        });
    </script>
</head>

<body style="font-size: 36px;">
<div id="pos38"></div>
<div class="wrapper">
    <header class="head2home">
        <a href="/" class="logo"></a>
        <div class="rBtn">
            <a href="/" class="home">官网首页</a>
            <a href="/search.php" class="sch"></a>
        </div>
    </header>

    <section class="container">
        <input id="_j_uid" type="hidden" value="51518929">
        <input id="_j_redirecturl" type="hidden" value="">
        <article class="comment">
            <section class="comment_detail">
                <h1 id="headTitle"></h1>
                <ul class="comment_lsit" id="_j_commentlist" data-x="xxx" render-loop="list">
                    <li>
                        <a data-href="/mine/userProfiles.html?id=" render-key="list.user.id" render-fun="getHref" class="cl_ava" >
                            <img render-src="list.user.headImgUrl" >
                        </a>
                        <a data-href="/mine/userProfiles.html?id=" render-key="list.user.id" render-fun="getHref" class="cl_name" render-html="list.user.nickName"></a>
                        <a data-href="/mine/userProfiles.html?id=" render-key="list.user.id" render-fun="getHref" class="cl_rating" title="LV.4">LV.4</a>
                        <a role="button" class="cl_reply _j_reply" render-key="list.user.id" render-fun="replyBt" title="回复" >回复</a>    <div class="cl_time" render-html="list.createTime"></div>
                        <span class="h_content o" render-html="list.content" style="display: none"></span>
                        <div class="cl_con" render-key="list.replyToUser.nickName" render-fun="getRU" >
                        </div>
                    </li>

                </ul>
                <div class="show_more"><a role="button" class="_j_more" data-id="10241742" title="显示更多评论">显示更多评论<i class="public_sprite"></i></a></div>
            </section>
        </article>
        <section class="reply_box bgef" id="_js_replyBox" style="display: none;">
            <div class="reply_title">
                <div class="re-hd">我要回复</div>
                <div class="btn">
                    <a class="close _j_close"><i></i></a>
                    <a class="submit _j_submit"><i></i></a>
                </div>
            </div>
            <div class="reply-wrap"><textarea id="_j_replyarea" ></textarea></div>
        </section>

        <footer class="footer footer_comment foot-bar-reply">
            <div class="comment_replay"><input id="_j_replyinput" type="text" placeholder="回复"></div>
        </footer>
    </section>
</div>
</body>
</html>